package com.example.rpapp.record.command;


import com.example.rpapp.assembler.RecordAssembler;
import com.example.rpclient.dto.RecordAddCmd;
import com.example.rpclient.dto.data.RecordVo;
import com.example.rpdomain.gateway.RecordGateway;
import com.example.rpdomain.record.RecordEntity;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


@Slf4j
@Component
@AllArgsConstructor
public class RecordAddCmdExe {

    private final RecordGateway recordGateway;

    public RecordVo execute(RecordAddCmd cmd) {
        RecordEntity entity = recordGateway.save(RecordAssembler.toAddEntity(cmd));

        return RecordAssembler.toRecordVO(entity);
    }
}
